<template>
  <div class="newList">
    <div class="newList-title" v-if="titleConfigs.title && list.length>0">
      <span class="newList-title-p1 reset">Relevant News</span>
    </div>
    <ul class="news-box" >
      <li class="news-item" v-for="(i,index) in list" :key="index">
        <newsItem :i="i"></newsItem>
      </li>
    </ul>
  </div>
</template>

<script type="text/ecmascript-6">
import dings from "../../assets/img/icon-ding.png";
import { getchannelinfolist } from "../../api/sort";
import newsItem from "./newstLi";
export default {
  props: ["titleConfig", "limit"],
  data() {
    return {
      titleConfigs: this.titleConfig || {},
      dings,
      list: [],
      page: 0,
      finished: false,
      pagesize: 10,
      error: false,
      loading: false,
      channel: this.$route.query.channel //代表菜单种类
    };
  },
  components: {
    newsItem
  },
  watch: {
    $route(to, from) {
      this.getchannelist();
    }
  },
  methods: {
    //获取新闻信息
    getchannelist() {
      let obj = this.$route.query || {};
      obj.channel = this.channel;
      // obj.cid = "903";
      if (this.limit) {
        obj.limit = this.limit;
      }
      getchannelinfolist(obj).then(res => {
        if (res.code === "0000") {
          this.list = res.data || [];
        }
      });
    }
  },
  created() {
    this.getchannelist();
  }
};
</script>

<style scoped lang="less">
@import url("./news.less");
</style>
